package com.thread.pool;

import java.util.HashMap;
import java.util.Hashtable;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 *  创建了一个固定长度的线程池，而且以延迟或定时的方式来执行任务，类似于 Timer。
 */
public class NewScheduledThreadPoolTest01 {
    public static void main(String[] args) {
        ScheduledExecutorService scheduledThreadPool= Executors.newScheduledThreadPool(5);
        scheduledThreadPool.schedule(new Runnable() {
            @Override
            public void run() {
                System.out.println("线程名："+Thread.currentThread().getName());
            }
        },3, TimeUnit.SECONDS); // 延迟3秒执行
    }

}
